package com.iterator.controller.web.promotionController;

import com.iterator.bean.web.pojo.BaseRespVo;
import com.iterator.bean.web.pojo.zql.InfoData;
import com.iterator.bean.web.pojo.zql.GrouponRules;
import com.iterator.bean.web.zql.bo.GrouponRuleBO;
import com.iterator.bean.web.zql.bo.ListRecordBO;
import com.iterator.service.web.promotionService.GrouponService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : L
 * @ProjectName : project-2
 * @Date : 1/10/2021
 * @Description :
 */
@RestController
@RequestMapping("admin/groupon")
public class GrouponController {
    @Autowired
    GrouponService grouponService;

    @RequestMapping("listRecord")
    @RequiresPermissions("admin:groupon:read")
    public BaseRespVo grouponListRecord(Integer page, Integer limit, String sort, String order,Integer goodsId) {
        return BaseRespVo.ok();
    }
    @RequestMapping("list")
    @RequiresPermissions("admin:groupon:list")
    public BaseRespVo list(ListRecordBO listRecordBO) {
        InfoData<GrouponRules> grouponRulesInfoData = grouponService.queryGrouponRuleList(listRecordBO);
        return BaseRespVo.ok(grouponRulesInfoData);
    }

    @RequestMapping("create")
    @RequiresPermissions("admin:groupon:create")
    public BaseRespVo create(@RequestBody GrouponRuleBO grouponRuleBO) {
        GrouponRules grouponRules = grouponService.insertGrouponRule(grouponRuleBO);
        return BaseRespVo.ok(grouponRules);
    }

    @RequestMapping("update")
    @RequiresPermissions("admin:groupon:update")
    public BaseRespVo update(@RequestBody GrouponRules grouponRules){
        grouponService.updateGrouponRule(grouponRules);
        return BaseRespVo.ok();
    }

    @RequestMapping("delete")
    @RequiresPermissions("admin:groupon:delete")
    public BaseRespVo delete(GrouponRules grouponRules){
        grouponService.deleteGrouponRule(grouponRules);
        return BaseRespVo.ok();
    }

}
